package com.kingschan.jeasytag.tag.grid;
import javax.servlet.jsp.JspException;
import com.kingschan.jeasytag.core.annotations.tag.*;

/**
 * 树形表格 - TreeGrid 从$.fn.datagrid.defaults.继承,覆盖默认值$.fn.treegrid.defaults.
 * treegrid 是使用显示分层数据在grid中,treegrid 是基于datagrid和关联treeview 和关联可编辑的grid,treegrid
 * 允许你创建定制的,异步加载展开行数据, 和显示分层的数据在多列中. 
 * @author kingschan
 * date:2013-4-25
 */
@TagMetaData(CssClass = "easyui-treegrid", tag = "table")
public class TreeGrid extends GridTag {
	private static final long serialVersionUID = 1L;
	@StringField(description="定义键字段标识一个tree节点,该项是必须的.")
	private String idField;
	@StringField(description="定义tree节点字段,该项是必须的")	
	private String treeField;
	@BooleanField(description="定义当节点展开/关闭的时候,是否显示动画效果.")
	private String animate; 
	@EventField(args={"param","success","error"},description="定义如何从远程服务器端加载数据. 返回false将终止这个动作. 这个函数提供一下参数 :param: 传递给远程服务器的参数对象.success(data): 检索数据成功之后执行的回调函数.error(): 当检索数据失败的时候调用的回调函数.error(): the callback function that will be called when failed to retrieve data.")
	private String loader; 
	@EventField(args={"data","parentId"},description="返回过滤后的显示数据.")
	private String loadFilter;

	//event
	@EventField(args="row",description="当用户点击一个节点时触发.")
	private String onClickRow;   
	@EventField(args="row",description="当用户双击一个节点时触发. ")
	private String onDblClickRow;  
	@EventField(args={"field","row"},description="当用户点击一个表格的时触发. ")
	private String onClickCell;  
	@EventField(args={"field","row"},description="当用户双击一个表格的时触发. ")
	private String onDblClickCell;  
	@EventField(args={"row","param"},description="一个请求去加载数据之前触发, 返回false将取消加载动作. ")
	private String onBeforeLoad;  
	@EventField(args={"row","data"},description="数据加载成功之后触发.")
	private String onLoadSuccess;   
	@EventField(args={"arguments"},description="数据加载失败之后触发,arguments 参数和jQuery.ajax的error函数一样. ")
	private String onLoadError;  
	@EventField(args={"row"},description="节点展开之前触发,返回false将取消展开动作. ")
	private String onBeforeExpand ; 
	@EventField(args={"row"},description=" 节点展开后触发. ")
	private String onExpand; 
	@EventField(args={"row"},description="节点折叠之前触发,返回false取消折叠动作. ")
	private String onBeforeCollapse;  
	@EventField(args={"row"},description="节点折叠后触发. ")
	private String onCollapse;  
	@EventField(args={"e","row"},description="在节点上右键点击触发.")
	private String onContextMenu;  
	@EventField(args={"row"},description="用户开始编辑一个节点时触发.")
	private String onBeforeEdit;   
	@EventField(args={"row","changes"},description="用户结束编辑节点时触发.")
	private String onAfterEdit;  
	@EventField(args={"row"},description="用户取消编辑节点时触发 ")
	private String onCancelEdit ;






	@Override
	public int doStartTag() throws JspException {		
//		this.setColumns(new ArrayList<ColumnTag>());
//		this.setFrozenColumns(new ArrayList<ColumnTag>());
//		this.setCheckBoxColumns(new ArrayList<ColumnTag>());
//		
//		try {
//			
//			JSONObject args = null;
//			args=null==this.getQueryParams()?new JSONObject():new JSONObject(this.getQueryParams());
//			args.put("target", new MD5().getMD5ofStr(this.getId()+ServletUtil.getRequestURI(pageContext)));
//			this.setQueryParams(args.toString());
//			this.pageContext.getOut().write(TagParseFactory.executeParse(this));
//		} catch (Exception e) {		
//			e.printStackTrace();
//		}
		//return EVAL_PAGE;
		return super.doStartTag();
	}





	@Override
	public int doEndTag() throws JspException {
		// TODO Auto-generated method stub
		return super.doEndTag();
	}




	public String getIdField() {
		return idField;
	}
	public void setIdField(String idField) {
		this.idField = idField;
	}
	public String getTreeField() {
		return treeField;
	}
	public void setTreeField(String treeField) {
		this.treeField = treeField;
	}
	public String getAnimate() {
		return animate;
	}
	public void setAnimate(String animate) {
		this.animate = animate;
	}
	public String getLoader() {
		return loader;
	}
	public void setLoader(String loader) {
		this.loader = loader;
	}
	public String getLoadFilter() {
		return loadFilter;
	}
	public void setLoadFilter(String loadFilter) {
		this.loadFilter = loadFilter;
	}
	public String getOnClickRow() {
		return onClickRow;
	}
	public void setOnClickRow(String onClickRow) {
		this.onClickRow = onClickRow;
	}
	public String getOnDblClickRow() {
		return onDblClickRow;
	}
	public void setOnDblClickRow(String onDblClickRow) {
		this.onDblClickRow = onDblClickRow;
	}
	public String getOnClickCell() {
		return onClickCell;
	}
	public void setOnClickCell(String onClickCell) {
		this.onClickCell = onClickCell;
	}
	public String getOnDblClickCell() {
		return onDblClickCell;
	}
	public void setOnDblClickCell(String onDblClickCell) {
		this.onDblClickCell = onDblClickCell;
	}
	public String getOnBeforeLoad() {
		return onBeforeLoad;
	}
	public void setOnBeforeLoad(String onBeforeLoad) {
		this.onBeforeLoad = onBeforeLoad;
	}
	public String getOnLoadSuccess() {
		return onLoadSuccess;
	}
	public void setOnLoadSuccess(String onLoadSuccess) {
		this.onLoadSuccess = onLoadSuccess;
	}
	public String getOnLoadError() {
		return onLoadError;
	}
	public void setOnLoadError(String onLoadError) {
		this.onLoadError = onLoadError;
	}
	public String getOnBeforeExpand() {
		return onBeforeExpand;
	}
	public void setOnBeforeExpand(String onBeforeExpand) {
		this.onBeforeExpand = onBeforeExpand;
	}
	public String getOnExpand() {
		return onExpand;
	}
	public void setOnExpand(String onExpand) {
		this.onExpand = onExpand;
	}
	public String getOnBeforeCollapse() {
		return onBeforeCollapse;
	}
	public void setOnBeforeCollapse(String onBeforeCollapse) {
		this.onBeforeCollapse = onBeforeCollapse;
	}
	public String getOnCollapse() {
		return onCollapse;
	}
	public void setOnCollapse(String onCollapse) {
		this.onCollapse = onCollapse;
	}
	public String getOnContextMenu() {
		return onContextMenu;
	}
	public void setOnContextMenu(String onContextMenu) {
		this.onContextMenu = onContextMenu;
	}
	public String getOnBeforeEdit() {
		return onBeforeEdit;
	}
	public void setOnBeforeEdit(String onBeforeEdit) {
		this.onBeforeEdit = onBeforeEdit;
	}
	public String getOnAfterEdit() {
		return onAfterEdit;
	}
	public void setOnAfterEdit(String onAfterEdit) {
		this.onAfterEdit = onAfterEdit;
	}
	public String getOnCancelEdit() {
		return onCancelEdit;
	}
	public void setOnCancelEdit(String onCancelEdit) {
		this.onCancelEdit = onCancelEdit;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}


}
